using DailyPoetryH.Library.Services;

namespace DailyPoetryH.Library.Pages;

public partial class Initialization {
    protected override async Task OnAfterRenderAsync(bool firstRender) {
        if (!firstRender) {
            return;
        }

        if (!_poetryStorage.IsInitialized) {
            await _poetryStorage.InitializeAsync();
        }

        if (!_favoriteStorage.IsInitialized) {
            await _favoriteStorage.InitializeAsync();
        }

        await Task.Delay(1000);

        _navigationService.NavigateTo(NavigationServiceConstants.TodayPage);
    }
}